package util.http

trait Log {
  def errorEnabled: Boolean
  def warnEnabled: Boolean
  def debugEnabled: Boolean
  def infoEnabled: Boolean
  def error(mes: => Any = "", e: Throwable = null)
  def info(mes: => Any = "", e: Throwable = null)
  def debug(mes: => Any = "", e: Throwable = null)
  def warn(mes: => Any = "", e: Throwable = null)
}

trait Logable {
  protected def log: Log
  protected def error[A](mes: => A = "", ex: Throwable = null): Unit =
    if (log.errorEnabled)
      log.error(mes, ex)

  protected def warn[A](mes: => A = "", ex: Throwable = null): Unit =
    if (log.warnEnabled)
      log.warn(mes, ex)

  protected def debug[A](mes: => A = "", ex: Throwable = null): Unit =
    if (log.debugEnabled)
      log.debug(mes, ex)

  protected def info[A](mes: => A = "", ex: Throwable = null): Unit =
    if (log.infoEnabled)
      log.info(mes, ex)

}